package com.woniuxy.stage3demo.controller.controllerhpx;


import com.github.pagehelper.PageInfo;
import com.woniuxy.stage3demo.bean.caicai.UserBean;
import com.woniuxy.stage3demo.bean.caicai.UserInfoBean;
import com.woniuxy.stage3demo.bean.hpxbean.OrderBean;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import com.woniuxy.stage3demo.pageHelper.TableResult;
import com.woniuxy.stage3demo.service.hpxservice.IOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("/order")
@RestController
public class OrderController {

    @Resource
    private IOrderService orderServiceImpl;


    //关闭订单（只包括未付款状态的）


    //删除订单（只包括已关闭状态的）


    //分页查询
    @RequestMapping(value = "/page",produces = {"application/json;charset=utf-8"})
    public TableResult<OrderBean> findAllByParams(PageRequest request, OrderBean orderBean, String userName){
        System.out.println("订单编号："+orderBean.getOrderNo());
        System.out.println("账号："+userName);
        System.out.println("状态码："+orderBean.getStatus());

        if (userName != null){
            UserBean userBean = new UserBean();
            UserInfoBean userInfoBean = new UserInfoBean();
            userInfoBean.setName(userName);
            userBean.setUserInforBean1(userInfoBean);
            if (orderBean != null){
                orderBean.setUserBean(userBean);
            }else {
                OrderBean orderBean1 = new OrderBean();
                orderBean1.setUserBean(userBean);
            }
        }

        PageInfo<OrderBean> pageInfo = orderServiceImpl.findAllByParams(request,orderBean);
        //System.out.println(pageInfo);
        return new TableResult<OrderBean>(pageInfo.getTotal(),pageInfo.getList());

    }

}
